# To change this template, choose Tools | Templates
# and open the template in the editor.

module LoaderHelper
  def short_loader(div_id,html_options = {})
    html_options.merge!(
      :height => "' + $(\"#{html_options[:height_from]}\").getHeight() + '"
    ) if html_options[:height_from]
    html_options.merge!(
      :width => "' + $(\"#{html_options[:width_from]}\").getWidth() + '"
    ) if html_options[:width_from]
    html_options = {:height => '98%',:width => '100%'}.merge(html_options)
    "Element.update('#{div_id.to_s}','<table class=\"short_loader\" width=\"#{html_options[:width]}\"  height=\"#{html_options[:height]}\"><tr><td align=\"center\" valign=\"middle\">#{image_tag 'loader/short.gif'}</td></tr></table>');"
  end

  def snake_loader(div_id,html_options = {})
    html_options = {
      :height => '14px'
    }.merge(html_options)
    "Element.update('#{div_id.to_s}','#{image_tag 'loader/snake.gif',html_options}');"
  end

  def text_loader(div_id,html = nil)
    if html
      "Element.update('#{div_id.to_s}','#{html}');"
    else
      "Element.update('#{div_id.to_s}','<span style=\"font-size:11px;text-align:center;font-weight:normal;color:#8E8E8E;\">处理中...</span>');"
    end
  end

  def thick_box_loader(div_id,html_options = {})
    html_options.merge!(
      :height => "' + $(\"#{html_options[:height_from]}\").getHeight() + '"
    ) if html_options[:height_from]
    html_options.merge!(
      :width => "' + $(\"#{html_options[:width_from]}\").getWidth() + '"
    ) if html_options[:width_from]
     html_options = {:height => '98%',:width => '100%'}.merge(html_options)
    "Element.update('#{div_id.to_s}','<table width=\"#{html_options[:width]}\"  height=\"#{html_options[:height]}\"><tr><td align=\"center\" valign=\"middle\">#{image_tag 'loader/thick_box.gif'}</td></tr></table>');"
  end

  def thanks(div_id,text,html_options = {})
    html_options.merge!(
      :height => "' + $(\"#{html_options[:height_from]}\").getHeight() + '"
    ) if html_options[:height_from]
    html_options.merge!(
      :width => "' + $(\"#{html_options[:width_from]}\").getWidth() + '"
    ) if html_options[:width_from]
    "Element.update('#{div_id.to_s}','<table width=\"#{html_options[:width]}\"  height=\"#{html_options[:height]}\"><tr><td align=\"center\" valign=\"middle\">#{text}</td></tr></table>');"
  end
end
